<?php
/**
 * Created by PhpStorm.
 * User: huihu
 * Date: 2016/5/11
 * Time: 18:44
 */

namespace app\app\controller;


use app\app\model\Order;
use think\Hook;

use think\Request;

class Api
{
    public function app(){
        $action = Request::instance()->post('action');
        $action_get = Request::instance()->get('action');
        if (!$action && !$action_get){
            return 101;
        }
        if ($action)
            $req = $action;
        else
            $req = $action_get;

        $action = explode('.',$req);
        list($class,$method) = $action;
        if (!class_exists('\app\app\controller\\'.$class)){
            return 102;
        }
        $obj = '\app\app\controller\\'.$class;
        $obj = new $obj();
        if (!method_exists($obj,$method)){
            return 103;
        }

        $rs = $obj->$method();
        //行为扩展 处理返回  本项目不做用户身份验证
        $result = Hook::exec('app\\app\\behavior\\Response','return_data',$rs);

        return $result;
    }


}